<template>
        <el-container class="layout-container-demo" style="height: 500px">
            <el-aside width="200px">
                <el-scrollbar>
                    <el-menu  @select="show">
                        <el-sub-menu index="1" >
                            <template #title>
                                <el-icon><Avatar /></el-icon>个人中心
                            </template>
                            <el-menu-item-group>
                                <el-menu-item index="1-1">个人信息</el-menu-item>
                            </el-menu-item-group>
                        </el-sub-menu>
                        <el-sub-menu index="2" v-if="store.auth.role!='学生'">
                            <template #title>
                                <el-icon><User /></el-icon>用户管理
                            </template>
                            <el-menu-item-group>
                                <el-menu-item index="2-1" v-if="store.auth.role!='学生'">学生信息管理</el-menu-item>
                            </el-menu-item-group>
                            <el-menu-item-group>
                                <el-menu-item index="2-2" v-if="store.auth.role=='管理员'">辅导员信息管理</el-menu-item>
                            </el-menu-item-group>
                        </el-sub-menu>
                        <el-sub-menu index="3" v-if="store.auth.role=='管理员'">
                            <template #title>
                                <el-icon><User /></el-icon>培养管理
                            </template>
                            <el-menu-item-group>
                              <el-menu-item index="3-1" v-if="store.auth.role=='管理员'">方案管理</el-menu-item>
                                <el-menu-item index="3-2" v-if="store.auth.role=='管理员'">学院专业管理</el-menu-item>
                                <el-menu-item index="3-3" v-if="store.auth.role=='管理员'" >年级管理</el-menu-item>
                               <el-menu-item index="3-4">课程管理</el-menu-item>
                              <el-menu-item index="3-5" v-if="store.auth.role!='学生'">课程类别管理</el-menu-item>
                            </el-menu-item-group>
                        </el-sub-menu>
                        <el-sub-menu index="4">
                            <template #title>
                                <el-icon><Reading /></el-icon>成绩管理
                            </template>
                            <el-menu-item index="4-1">课程成绩信息管理</el-menu-item>
                            <el-menu-item index="4-2">等级成绩信息管理</el-menu-item>
                            <el-menu-item index="4-3" v-if="store.auth.role=='管理员'">审核成绩信息管理</el-menu-item>
                            <el-menu-item index="4-4" v-if="store.auth.role!='学生'">上传信息提示</el-menu-item>
                        </el-sub-menu>
                        <el-sub-menu index="5">
                            <template #title>
                                <el-icon><Monitor /></el-icon>预警管理
                            </template>
                            <el-menu-item index="5-1">静态预警信息管理</el-menu-item>
                            <el-menu-item index="5-2">动态预警信息管理</el-menu-item>
                            <el-menu-item index="5-3" v-if="store.auth.role!='学生'">预警参数设置</el-menu-item>
                        </el-sub-menu>
                        <el-sub-menu index="6">
                            <template #title>
                                <el-icon><DataBoard /></el-icon>数据统计
                            </template>
                            <el-menu-item index="6-1">数据统计图</el-menu-item>
                            <el-menu-item index="6-2" @click="tern">毕业授位资格统计</el-menu-item>
                            <el-menu-item index="6-3" v-if="store.auth.role!='学生'">留级信息审核</el-menu-item>
                            <el-menu-item index="6-4" v-if="store.auth.role!='学生'">系统数据统计</el-menu-item>
                        </el-sub-menu>
                    </el-menu>
                </el-scrollbar>
            </el-aside>

            <el-container>
                <el-header >
                    <div style="text-align: center;font-size: 20px">高校二级学院学生学业预警系统</div>
                    <div class="topRight" style="text-align: right; font-size: 12px">
                        <span style="font-size:20px;color:black">{{identity}}</span>
                        <span>{{user}}</span>
                        <el-button type="danger" plain @click="logout()">退出登录</el-button>
                    </div>
                </el-header>
                <el-main>
                    <div v-show="page==''">欢迎{{user}},进入我们的预警系统！</div>
                    <div v-show="page=='1-1'"><own></own></div>
                    <div v-show="page=='2-1'"><stuInfo></stuInfo></div>
                    <div v-show="page=='2-2'"><teacher></teacher></div>
                    <div v-show="page=='3-1'"><colleges></colleges></div>
                    <div v-show="page=='3-2'"><collegeMajor></collegeMajor></div>
                    <div v-show="page=='3-3'"><grade></grade></div>
                    <div v-show="page=='3-4'"><course></course></div>
                    <div v-show="page=='3-5'"><courseType></courseType></div>
                    <div v-show="page=='4-1'"><score></score></div>
                    <div v-show="page=='4-2'"><levelScore></levelScore></div>
                    <div v-show="page=='4-3'"><check></check></div>
                    <div v-show="page=='4-4'"><aler></aler></div>
                    <div v-show="page=='5-1'"><warn></warn></div>
                    <div v-show="page=='5-2'"><warn1></warn1></div>
                    <div v-show="page=='5-3'"><setting></setting></div>
                    <div v-show="page=='6-1'"><total></total></div>
                    <div v-show="page=='6-2'"><exam></exam></div>
                    <div v-show="page=='6-3'"><repetition></repetition></div>
                    <div v-show="page=='6-4'"><sysD></sysD></div>
                </el-main>
            </el-container>
        </el-container>
</template>
<script setup>
import { get } from '@/utils/request.js'
import {ElMessage} from 'element-plus'
import router from '@/router'
import { ref,onMounted } from 'vue'
import { User, Message, Reading,Avatar,Folder,Monitor,DataBoard } from '@element-plus/icons-vue'
import own from '@/views/OwnVue.vue'
import stuInfo from '@/views/stuInfo.vue'
import course from '@/views/CourseVue.vue'
import score from '@/views/ScoreVue.vue'
import levelScore from '@/views/LevelScoreVue.vue'
import warn from '@/views/WarningVue.vue'
import warn1 from '@/views/WarningVue1.vue'
import setting from '@/views/SettingVue.vue'
import sysD from '@/views/SysDataVue.vue'
import total from '@/views/TotalVue.vue'
import teacher from '@/views/TeacherVue.vue'
import check from '@/views/CheckVue.vue'
import aler from '@/views/AlertVue.vue'
import exam from '@/views/ExamineVue.vue'
import collegeMajor from '@/views/CollegeMajorVue.vue'
import grade from '@/views/GradeVue.vue'
import repetition from '@/views/RepetitionVue.vue'
import courseType from '@/views/CourseTypeVue.vue'
import colleges from '@/views/CollegesVue.vue'
import {userStore} from '@/stores/counter.js'

const user = ref('')
const identity=ref('')
const page = ref('')
const store=userStore()


get('/getUser',(message)=>{
    user.value = message.name
    store.auth.user = message.name
    if(message.role=='1'){
    identity.value='管理员'
    store.auth.role='管理员'
    }else if(message.role=='2'){
    identity.value='辅导员'
    store.auth.role='辅导员'
    }else {identity.value='学生'
    store.auth.role='学生'
    }
    })


const logout=()=>{
get('/api/auth/logout',(message)=>{
ElMessage.success(message)
store.auth.user=null
store.auth.role=null
store.auth.name=null
router.push('/')
})
}

const show=(index)=>{
page.value=index
}

</script>
<style scoped>
    .layout-container-demo .el-header {
  position: relative;
  background-color: var(--el-color-primary-light-7);
  color: var(--el-text-color-primary);
}
.layout-container-demo .el-aside {
  color: var(--el-text-color-primary);
  background: var(--el-color-primary-light-8);
}
.layout-container-demo .el-menu {
  border-right: none;
}
.layout-container-demo .el-main {
  padding: 0;
}
.layout-container-demo .toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  right: 20px;
}
</style>